<?php

//weather 

	$moduleRequest = "";

	if (isset($_REQUEST['param']))
		$moduleRequest = $_REQUEST['param'];

	$pageUrl = "http://www.google.ca/search?hl=en&source=hp&btnG=Google+Search&meta=&q=weather+".urlencode($moduleRequest);

	$pageHTML = getListenPage($pageUrl);

	$firstLink = getFirstItemUrl($pageHTML);




	function getListenPage($fvsWebUrl)
	{

		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL,$fvsWebUrl);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt($ch, CURLOPT_TIMEOUT, 60);
		$ret = curl_exec ($ch);
		curl_close($ch);

		return $ret;
	}
	function getFirstItemUrl($pageHTML)
	{

$parts = explode("<div style=\"font-size:140%\"><b>", $pageHTML);
//echo count($parts);
//echo ($parts[0]);
$end = strpos($parts[1], "<");
$result = substr($parts[1], 0, $end);
echo $result;
	}
?> 
